<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.toncen.samepms.demo.domain.DemoFather"/>
<jsp:directive.page import="com.toncen.samepms.demo.dao.DemoFatherDao"/>
<jsp:directive.page import="com.sky.dataimport.parser.DynamicRowExcelDataParser"/>
<jsp:directive.page import="com.sky.dataimport.parser.DynamicCellExcelDataParser"/>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="g" uri="/fishergrid-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title><s:property value="operate"/>主表示例</title>
	<%@include file="/share/header.jsp"%>
	<g:header theme="${sessionScope.skinCon.gridSkin}"/>
	<s:head/>	
  </head>
  <body>
  
	<script type="text/javascript">
		//加工
		function onDoProcess(name,g){
			var parameters={
				url:'<s:url action='new' namespace='/demo/father'/>?processId=/demo/demofather.process.xml',
				tip:'加工',
				title:'【新增主表示例】',
				source : window,
				buttons:[top.MyWindow.Save,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:1,
				tipstitle:'友情提示：',
				tipscontent:'操作完从表示例后，请点击最下面的保存按钮进行保存，不点击保存则全部修改无效；'				
			};
			onDoOpen(parameters);
		}	
		//新增
		function onDoAdd(name,g){
			var options={
				title:'【新增主表示例】',
				url:'<s:url action='new' namespace='/demo/father'/>?processId=/demo/demofather.process.xml',
				source : window,
				buttons:[top.MyWindow.SaveNoClose,top.MyWindow.Save,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:1,
				tipstitle:'友情提示：',
				tipscontent:'操作完从表示例后，请点击最下面的保存按钮进行保存，不点击保存则全部修改无效；'
			};
			top.MyWindow.open(options);
		}
		//Excel批量导入
		function onDoExcelImport(name,g){
			var options={
				title:'【Excel批量导入】',
				url:'<s:url action='importExcel' namespace='/office'/>?modelClassName=<%=DemoFather.class.getName()%>&modelClassName=<%=DemoFather.class.getName()%>&accessClassName=<%=DemoFatherDao.class.getName()%>&accessClassName=<%=DemoFatherDao.class.getName()%>&parserClassName=<%=DynamicRowExcelDataParser.class.getName()%>&parserClassName=<%=DynamicCellExcelDataParser.class.getName()%>&templatePath=/template/excel/DemoFather.xls',
				source : window,
				buttons:[top.MyWindow.Import,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:0.8,
				tipstitle:'',
				tipscontent:''
			};
			top.MyWindow.open(options);
		}			
		//修改		
		function onDoOperateRenderer(tdDiv,pid){
			var operationRight  = '<s:property value="right.modifyRight"/>';
			var url;
			var htmlText;
			var button;
			if(operationRight=='1')
			{
				url = '<s:url action="edit" namespace='/demo/father'/>?processId=/demo/demofather.process.xml&domain.id='+pid;
				htmlText = '<a href="javascript:void(0);" title="修改">修改</a>';
				var options={
					title:'【修改主表示例】',
					url:url,
					source : window,
					buttons:[top.MyWindow.SaveNoClose,top.MyWindow.Save,top.MyWindow.Cancel],
					multiplewidth:1,
					multipleheight:1,
					tipstitle:'友情提示：',
					tipscontent:'操作完从表示例后，请点击最下面的保存按钮进行保存，不点击保存则全部修改无效；'
				};
			}
			else
			{
				url = '<s:url action="view" namespace='/demo/father'/>?processId=/demo/demofather.process.xml&readonly=true&domain.id='+pid;
				htmlText = '<a href="javascript:void(0);" title="查看【'+$(tdDiv).html()+'】详细信息">查看</a>';
				var options={
					title:'【查看主表示例】',
					url:url,
					source : window,
					buttons:[top.MyWindow.Close],
					multiplewidth:1,
					multipleheight:1,
					tipstitle:'',
					tipscontent:''
				};			
			}
			$(tdDiv).html("");//去除原有的内容
			$(tdDiv).append($(htmlText).click(function(){//添加链接
											top.MyWindow.open(options);
										})
							);
		}	
		//查看		
		function onDoNameRenderer(tdDiv,pid){
			var options={
				title:'【查看主表示例】',
				url:'<s:url action="view" namespace='/demo/father'/>?processId=/demo/demofather.process.xml&readonly=true&domain.id='+pid,
				source : window,
				buttons:[top.MyWindow.Close],
				multiplewidth:1,
				multipleheight:1,
				tipstitle:'',
				tipscontent:''
			};			
			var viewhtml='<a href="javascript:void(0);" title="查看【'+$(tdDiv).html()+'】详细信息">'+$(tdDiv).html()+'</a>';
			$(tdDiv).html("");//去除原有的内容
			$(tdDiv).append($(viewhtml).click(function(){//添加链接
											top.MyWindow.open(options);
										})
							);				
		}		
		//删除
		function onDoDelete(name,grid){
			onDoAjax({url:'<s:url action='deletes' namespace='/demo/father'></s:url>'});
		}	
		//启用
		function onDoEnable(name,grid){
			onDoAjax({url:'<s:url action='changes' namespace='/demo/father'></s:url>?domain.state=1',tip:'启用'});
		}
		//停用
		function onDoUnEnable(name,grid){
			onDoAjax({url:'<s:url action='changes' namespace='/demo/father'></s:url>?domain.state=2',tip:'停用'});
		}
		//复制
		function onDoCopy(name,grid){
			onDoAjax({url:'<s:url action='copys' namespace='/demo/father'></s:url>?copyName=name',tip:'复制'});
		}
		//批量保存
		function onDoSaves(name,grid){
			fisherSaves({url:'<s:url action='saves' namespace='/demo/father'></s:url>'});
		}						
	</script>  
  	<s:actionerror/>	
  	<g:grid title="主表示例列表" name="/demo/demofather.fisher.xml">
  		<s:if test="right.checkBoxRight==1">
  		<g:select/>
  		</s:if>
  		<s:if test="right.size==0||right.addRight==1">
  		<g:separator/>  
  		<g:button name="新增" styleClass="fisherAdd" onclick="onDoAdd"/>
  		</s:if>
  		<g:separator/>  
  		<g:button name="保存" styleClass="fisherSave" onclick="onDoSaves"/>  		
  		<g:separator/>  
  		<g:button name="加工" styleClass="fisherAdd" onclick="onDoProcess"/>
  		<s:if test="right.size==0||right.importExcelRight==1">
  		<g:separator/>  
		<g:button name="Excel批量导入" styleClass="fisherDownload" onclick="onDoExcelImport"/>  
		</s:if>		
		<s:if test="right.size==0||right.enableRight==1">
  		<g:separator/> 
  		<g:button name="启用" styleClass="fisherCheck" onclick="onDoEnable"/>
  		</s:if>
  		<s:if test="right.size==0||right.unEnableRight==1">
  		<g:separator/>  
  		<g:button name="停用" styleClass="fisherUncheck" onclick="onDoUnEnable"/>
  		</s:if>
  		<s:if test="right.size==0||right.copyRight==1">
  		<g:separator/>  
  		<g:button name="复制" styleClass="fisherCopy" onclick="onDoCopy"/>
  		</s:if>
  		<s:if test="right.size==0||right.delRight==1">
  		<g:separator/>   		  		 
  		<g:button name="删除" styleClass="fisherDelete" onclick="onDoDelete"/>
  		</s:if>
  		<g:separator/>   				
  		<g:query/>
  		<s:if test="right.size==0||right.exportExcelRight==1">
  		<g:separator/>
  		<g:export/>  	
  		</s:if>	
  	</g:grid>
	<jsp:include flush="true" page="/share/flow.jsp">
		<jsp:param name="code" value="demo_state"/>
		<jsp:param name="process" value="[{'value':'1','name':'待推荐','remark':'等待科级秘书推荐或者申请'},{'value':'2','name':'待修改','remark':'待专家补充材料'},{'value':'3','name':'待审核','remark':'待本单位科技秘书审核或厅科技处审批'},{'value':'4','name':'已激活','remark':'用户帐号可以正常使用'}]"/>			
		<jsp:param name="exclude" value="40,50"/>
		<jsp:param name="value" value="20"/>
	</jsp:include>
  </body>
</html>
